import { loginApi } from '@/api/user.js'
import { getToken, setToken } from '@/utils/storage.js'
export default {
	state() {
		return {
			token: getToken()
		}
	},
	mutations: {
		changeToken(state, token) {
			state.token = token
		}
	},
	actions: {
		async asyncLogin({ commit }, ruleForm) {
			const res = await loginApi(ruleForm)
			console.log(res, 99887)
			/* token=》vuex+本地存储 */
			commit('changeToken', res.data.data.token)
			setToken(res.data.data.token)
		}
	},
	getters: {},
	namespaced: true
}
